package com.alvin.demo.utils;

import com.alvin.demo.common.utils.JacksonUtils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ResponseUtils {

    public static void out(HttpServletResponse response , Object object) throws IOException {
        //返回结果
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        // 获取PrintWriter对象
        PrintWriter out = response.getWriter();
        out.print(JacksonUtils.toString(object));
        // 释放PrintWriter对象
        out.flush();
        out.close();
    }

}
